package com.jk.dmuserprovider.controller;



import com.jk.dmcommon.entity.OrderEntity;
import com.jk.dmcommon.entity.ShippingEntity;
import com.jk.dmcommon.entity.CouponEntity;
import com.jk.dmcommon.entity.TreeEntity;
import com.jk.dmcommon.entity.LeaveEntity;
import com.jk.dmcommon.entity.SessionEntity;
import com.jk.dmuserprovider.service.TreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.jk.dmcommon.LybEntity.UserEntity;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author 赵优秀
 * @version 1.0.0
 * @ClassName TreeController.java
 * @Description TODO
 * @createTime 2021年09月07日 11:29:00
 */
@RequestMapping("tree")
@RestController
public class TreeController {
    @Autowired
    private TreeService treeService;
    @RequestMapping("getTree")
    public List<TreeEntity> getTree(@RequestParam("pid") Integer pid){
        return treeService.getTree(pid);
    }
    /**
     * @title 回显
     * @description
     * @author 赵优秀
     * @updateTime 2021/9/7 19:42
     * @throws
     */
    @RequestMapping("getByid")
    public UserEntity getByid(){
        UserEntity user = treeService.getByid();
        return user;
    }

        /**
         * @title 修改
         * @description
         * @author 赵优秀
         * @updateTime 2021/9/7 20:43
         * @throws
         */

        @PostMapping(value = "updateUser")
        public String updateUser(@RequestBody UserEntity user){
            return treeService.updateUser(user);
        }

        /**
         * @title 查询收货地址
         * @description
         * @author 赵优秀
         * @updateTime 2021/9/8 14:06
         * @throws
         */
        @RequestMapping("findAddress")
        public List<ShippingEntity> findAddress(){
            return treeService.findAddress();
        }

        /**
         * @title 新增收货地址
         * @description
         * @author 赵优秀
         * @updateTime 2021/9/8 15:46
         * @throws
         */
        @PostMapping("addAddress")
        public void addAddress(@RequestBody ShippingEntity shipping){
            treeService.addAddress(shipping);
        }
        /**
         * @title 删除地址
         * @description
         * @author 赵优秀
         * @updateTime 2021/9/8 16:29
         * @throws
         */
        @RequestMapping("delAddress")
        public void delAddress(@RequestParam("id") Integer id){
            treeService.delAddress(id);
        }
        /**
         * @title 回显地址
         * @description
         * @author 赵优秀
         * @updateTime 2021/9/8 16:47
         * @throws
         */
        //回显地址
        @RequestMapping("getAddress")
        public ShippingEntity getAddress(@RequestParam("id") Integer id){
            return treeService.getAddress(id);
        }

        /**
         * @title 查询优惠券
         * @description
         * @author 赵优秀
         * @updateTime 2021/9/8 19:10
         * @throws
         */
        @RequestMapping("findCoupon")
        public List<CouponEntity> findCoupon(@RequestBody CouponEntity coupon){
            return treeService.findCoupon(coupon);
        }
        /**
         * @title 查询订单
         * @description
         * @author 赵优秀
         * @updateTime 2021/9/8 21:25
         * @throws
         */
        @PostMapping("findOrder")
        public List<OrderEntity> findOrder(@RequestBody OrderEntity orderEntity){
            return treeService.findOrder(orderEntity);
        }

            /**
             * @title 查询场次
             * @description
             * @author 赵优秀
             * @updateTime 2021/9/9 14:32
             * @throws
             */
            @RequestMapping("getSession")
            public List<SessionEntity> getSession(@RequestParam("goodsId") Integer goodsId){
                List<SessionEntity> list = treeService.getSession(goodsId);
                return list;
            }

            /**
             * @title 获取档次
             * @description
             * @author 赵优秀
             * @updateTime 2021/9/9 15:36
             * @throws
             */
            @RequestMapping("getLeave")
            public List<LeaveEntity> getLeave(@RequestParam("id") Integer id){
                return treeService.getLeave(id);
            }





}
